<?php
	include "public/commom/config.php";//引入配置连接数据库文件
	
	if($_POST){
		$account = $_POST["account"];//账号
		$password1 = $_POST["password1"];//密码
		$password2 = $_POST["password2"];//确认密码
		
		$sql = "SELECT * FROM user WHERE account = '$account'";//sql语句 - 查找账号是否存在
		
		$result = mysqli_query($conn, $sql);//result - 执行sql语句
		
		if(!mysqli_num_rows($result)) {//该账号是否存在
			//true
			if($password1 == $password2) {//判断两次输入的密码是否一致
				//true
				$sql1 = "INSERT INTO user (account, password) VALUES ('$account', '$password1')";//sql1语句  - 插入用户
				
				$result1 = mysqli_query($conn, $sql1);//result1 - 执行sql语句
				
				mysqli_close($conn);//关闭数据库连接
					
				header("Location: ./index.php");//跳转页面
			}else {
				//false
				echo "两次输入的密码不一致";
			}
			
		} else {
			//false
			echo "账号已存在";
		}
	}
?>